FROM alpine:latest
# MAINTAINER 
MAINTAINER beige <2433141241@qq.com>
ENV APP_VERSION 1.20.2
RUN wget https://nginx.org/download/nginx-${APP_VERSION}.tar.gz && \
    tar xf nginx-${APP_VERSION}.tar.gz 
# 修改下载地址
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk update
# 创建用户
RUN adduser   -s /sbin/nologin -H  -D  nginx
# 安装依赖
RUN apk add gcc g++ make pcre-dev openssl-dev  zlib-dev
# 编译安装
RUN cd nginx-${APP_VERSION} && ./configure --prefix=/app/ --user=nginx --group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module && make && make install 
# 覆盖配置文件
COPY nginx.conf /app/conf/
# 设置权限
RUN chown  nginx.nginx -R /app 
# 清理垃圾数据
RUN rm -rf /var/cache/apk  && rm -rf /nginx* 
# 设置工作目录
WORKDIR /app
# 暴露端口
EXPOSE 80 443
# 启动命令
CMD /app/sbin/nginx -g "daemon off;"

